import jsCookie from 'js-cookie'

export function setCookie(key, value) {
    if (value) {
        jsCookie.set(key, JSON.stringify(value), {expires: 7});
    }
    if (typeof(value) == 'number' && value == 0) {
        jsCookie.set(key, value, {expires: 7});
    }
    if (typeof(value) == 'boolean' && value == false) {
        jsCookie.set(key, false, {expires: 7});
    }
}

export function getCookie(key) {
    var value = jsCookie.get(key);
    if (value) {
        return JSON.parse(value)
    }

}

export function clearAllCookie() {
    jsCookie.set("app.login_user", "", -1);
}
